//
// NeL - bindings
// Copyright (C) 2010 Naush
//
//This program is free software: you can redistribute it and/or modify
//it under the terms of the GNU Affero General Public License as
//published by the Free Software Foundation, either version 3 of the
//License, or (at your option) any later version.
//
//This program is distributed in the hope that it will be useful,
//but WITHOUT ANY WARRANTY; without even the implied warranty of
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//GNU Affero General Public License for more details.
//
//You should have received a copy of the GNU Affero General Public License
//along with this program.  If not, see <http://www.gnu.org/licenses/>.
package org.ryzom.nel.misc;

public class CTimeoutAssertionThread extends IRunnable {
  private long swigCPtr;

  public CTimeoutAssertionThread(long cPtr, boolean cMemoryOwn) {
    super(nelmiscJNI.CTimeoutAssertionThread_SWIGUpcast(cPtr), cMemoryOwn);
    swigCPtr = cPtr;
  }

  public static long getCPtr(CTimeoutAssertionThread obj) {
    return (obj == null) ? 0 : obj.swigCPtr;
  }

  protected void finalize() {
    delete();
  }

  public synchronized void delete() {
    if (swigCPtr != 0) {
      if (swigCMemOwn) {
        swigCMemOwn = false;
        nelmiscJNI.delete_CTimeoutAssertionThread(swigCPtr);
      }
      swigCPtr = 0;
    }
    super.delete();
  }

  public CTimeoutAssertionThread(long timeout) {
    this(nelmiscJNI.new_CTimeoutAssertionThread__SWIG_0(timeout), true);
  }

  public CTimeoutAssertionThread() {
    this(nelmiscJNI.new_CTimeoutAssertionThread__SWIG_1(), true);
  }

  public void run() {
    nelmiscJNI.CTimeoutAssertionThread_run(swigCPtr, this);
  }

  public void activate() {
    nelmiscJNI.CTimeoutAssertionThread_activate(swigCPtr, this);
  }

  public void deactivate() {
    nelmiscJNI.CTimeoutAssertionThread_deactivate(swigCPtr, this);
  }

  public void quit() {
    nelmiscJNI.CTimeoutAssertionThread_quit(swigCPtr, this);
  }

  public void timeout(long to) {
    nelmiscJNI.CTimeoutAssertionThread_timeout(swigCPtr, this, to);
  }

  public final static class TControl {
    public final static TControl ACTIVE = new TControl("ACTIVE");
    public final static TControl INACTIVE = new TControl("INACTIVE");
    public final static TControl QUIT = new TControl("QUIT");

    public final int swigValue() {
      return swigValue;
    }

    public String toString() {
      return swigName;
    }

    public static TControl swigToEnum(int swigValue) {
      if (swigValue < swigValues.length && swigValue >= 0 && swigValues[swigValue].swigValue == swigValue)
        return swigValues[swigValue];
      for (int i = 0; i < swigValues.length; i++)
        if (swigValues[i].swigValue == swigValue)
          return swigValues[i];
      throw new IllegalArgumentException("No enum " + TControl.class + " with value " + swigValue);
    }

    private TControl(String swigName) {
      this.swigName = swigName;
      this.swigValue = swigNext++;
    }

    private TControl(String swigName, int swigValue) {
      this.swigName = swigName;
      this.swigValue = swigValue;
      swigNext = swigValue+1;
    }

    private TControl(String swigName, TControl swigEnum) {
      this.swigName = swigName;
      this.swigValue = swigEnum.swigValue;
      swigNext = this.swigValue+1;
    }

    private static TControl[] swigValues = { ACTIVE, INACTIVE, QUIT };
    private static int swigNext = 0;
    private final int swigValue;
    private final String swigName;
  }

}
